#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <locale.h>
#include"game.h"
void menu()
{
	printf("**********************\n");
	printf("*****1->玩游戏********\n");
	printf("*****2->退出游戏******\n");
	printf("**********************\n");
}
void game()
{
	//创建二维数组
	char Board[ROW][COL] = { 0 };
	//初始化棋盘全部为空格
	InitBoard(Board, ROW, COL);
	//将二维数组初始化为可见棋盘
	DisplayBoard(Board, ROW, COL);
	char ch = 0;
	while (1)
	{
		//玩家下棋
		PlayerMove(Board, ROW, COL);
		//展示棋盘
		DisplayBoard(Board, ROW, COL);
		//判断输赢
		ch = IsWin(Board, ROW, COL);
		if (ch != 'C')
			break;
		//电脑下棋
		ComputerMove(Board, ROW, COL);
		//展示棋盘
		DisplayBoard(Board, ROW, COL);
		//判断输赢
		IsWin(Board, ROW, COL);
		if (ch != 'C')
			break;
	}
	if (ch == '*')
		printf("玩家获胜\n");
	else if (ch == '#')
		printf("电脑获胜\n");
	else
	{
		printf("平局\n");
	}
}
int main()
{
	setlocale(LC_ALL, "");
	srand((unsigned int)time(NULL));
	int input = 0;
	do
	{
		menu();
		printf("请选择\n");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 2:
			printf("游戏已经退出\n");
			break;
		default:
			printf("选择错误，请重新选择\n");
			break;
		}
	} while (input);

	return 0;
}